<?php

namespace common\logics\navigation;

use Yii;
use common\models\CacheModel;

/**
 * APP主题模型
 * ThemeLogic
 */
class ThemeLogic extends CacheModel {

    const THEME_DEFAULT = 1;
    const THEME_ACTIVITY = 2;
    const THEME_MATCH = 3;

    private static $theme = self::THEME_DEFAULT;

    public function __construct($config = array()) {
        parent::__construct($config);
        $this->listenTheme();
    }

    protected function listenTheme() {
        self::$theme = static::THEME_MATCH;
        $match = false;
        if ($match) {
            self::$theme = self::THEME_ACTIVITY;
        }
    }

    /**
     * 默认主题
     * @return array
     */
    public static function loadDefault() {
        return [
            'style' => static::THEME_DEFAULT,
            'config' => [
                'background_img' => 'http://api.lunengsports.net/static/img/ln_header_normal.png',
            ],
        ];
    }

    /**
     * 比赛主题
     * @return array
     */
    public static function loadMatch() {
        return [
            'style' => static::THEME_MATCH,
            'config' => [
                'home' => '贵州恒丰',
                'homg_icon' => 'http://192.168.0.105/lntsapp/apps/api/web/uploads/attachments/default/navi-icon/2.png',
                'away' => '山东鲁能泰山',
                'away_icon' => 'http://192.168.0.105/lntsapp/apps/api/web/uploads/attachments/default/navi-icon/1.png',
                'time' => '2018.3.4 周日',
                'weather' => '晴',
                'weather_data' => '24°C',
                'weather_icon' => 'http://192.168.0.105/lntsapp/apps/api/web/uploads/attachments/default/navi-icon/3.png',
                'background_img' => 'http://192.168.0.105/lntsapp/apps/api/web/uploads/attachments/default/navi-icon/4.png',
            ],
        ];
    }

    /**
     * 活动主题
     * @return array
     */
    public static function loadActivity() {
        return [
            'style' => static::THEME_ACTIVITY,
            'config' => [
                'background_img' => 'http://192.168.0.105/lntsapp/apps/api/web/uploads/attachments/default/navi-icon/5.png',
            ],
        ];
    }

    /**
     * 获取当前头部导航主题
     * @return array
     */
    public static function current() {
        return self::getCache();
    }

    public static function cacheDefault() {
        return [
            'style' => static::THEME_DEFAULT,
            'config' => [
                'background_img' => 'http://api.lunengsports.net/static/img/ln_header_normal.png',
            ],
        ];
    }

}
